package com.xframework.model;

import com.xframework.Base;

import javax.annotation.Nonnull;

/**
 * Created by xuning on 2021/1/13.
 */
public class SqlParamSeg {

    private String sql;

    private Object[] params;

    private boolean express = Boolean.FALSE;

    public SqlParamSeg(String sql) {
        this.setExpress(Boolean.TRUE);
        this.setSql(sql);
    }

    public SqlParamSeg(String sql, @Nonnull Object... params) {
        for (Object param : params) {
            if (!Base.isNotNull(param)) {
                return;
            }
        }
        this.setExpress(Boolean.TRUE);
        this.setSql(sql);
        this.setParams(params);
    }

    public SqlParamSeg(boolean express, String sql, @Nonnull Object... params) {
        if (express) {
            this.setExpress(express);
            this.setSql(sql);
            this.setParams(params);
        }
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public Object[] getParams() {
        return params;
    }

    public void setParams(Object[] params) {
        this.params = params;
    }

    public boolean getExpress() {
        return express;
    }

    public void setExpress(boolean express) {
        this.express = express;
    }
}
